package com.walker.controller;

import com.walker.config.AppConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TestController {

    @Autowired
    private AppConfig appConfig;

    @PostConstruct
    public void init() {
        System.out.println("AppConfig loaded: " + appConfig.getMessage());
        System.out.println("API Key: " + appConfig.getApiKey());
    }

    @GetMapping("/test-config")
    public String testConfig() {
        return appConfig.getMessage() + " - " + appConfig.getApiKey();
    }

    @GetMapping("/config-info")
    public Map<String, Object> getConfigInfo() {
        Map<String, Object> config = new HashMap<>();
        config.put("message", appConfig.getMessage());
        config.put("apiKey", appConfig.getApiKey());
        config.put("featureEnabled", appConfig.isFeatureEnabled());
        return config;
    }

    // 新增专门查看 TJ 列表的接口
    @GetMapping("/tj-list")
    public List<String> getTjList() {
        return appConfig.getTj();
    }
}